<template>
  <n-modal :show="state.dialogFormVisible" @onUpdateShow="close">
    <div class="illus-dia">
      <div class="nav">
        <div class="title">{{ state.title }}</div>
        <div class="close" @click="close">
          <i class="esayIcon esayIcon-guanbi1"></i>
        </div>
      </div>
      <div class="content">
        <n-scrollbar style="height: 40vh">
          <div v-html="state.html"></div>
        </n-scrollbar>
      </div>
    </div>
  </n-modal>
</template>
<script setup lang="ts">
import { NModal, NScrollbar } from 'naive-ui'
import { reactive } from 'vue'
interface stateInter {
  dialogFormVisible: boolean
  title: string
  html: string
}
const state: stateInter = reactive({
  dialogFormVisible: false,
  title: '',
  html: ''
})
const close = () => {
  state.dialogFormVisible = false
}
const open = (type: string) => {
  const titles = {
    USER_AGREEMENT: '用户协议',
    PRIVACY_POLICY: '隐私政策',
    UPLOAD_NOTE: '上传模型',
    WEBSITE_AGREEMENT: '网站协议',
    MATERIAL_UPDATE_DESCRIPTION: '网站素材上传说明',
    RECHARGE_AGREEMENT: '网站用户充值协议'
  }
  // systemApi.getTypeSetting(type).then(({ data }) => {
  //   state.html = data.content
  // })
  state.html = '我是富文本内容'
  state.title = titles[type] || '未知'
  state.dialogFormVisible = true
}
defineExpose({
  open
})
</script>

<style scoped lang="scss">
.illus-dia {
  width: 500px;
  background: #fff;
  border-radius: 15px;
  box-sizing: border-box;
  padding: 24px;
  .nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 24px;
    border-bottom: 1px solid #eeeeee;
    .title {
      font-size: 18px;
      font-family: PingFang SC, PingFang SC;
      font-weight: bold;
      color: #333333;
    }
    .close {
      cursor: pointer;
      i {
        font-size: 24px;
        color: #666666;
      }
    }
  }
  .content {
    padding-top: 20px;
  }
}
</style>
